<?php
/**
 * 头部菜单
 * User: adophper <hello@adophper.com>
 * Date: 2018/3/22
 * Time: 11:47
 */
?>
<nav class="navbar navbar-default">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collaplsed" data-toggle="collapse" data-target="#navigation" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>

            <div class="headerleft">
                <span class="logo_are flex">
                    <i class="head_icon"></i>
                    <em><?=Yii::$app->system->getSubtitle()?></em>
                </span>
            </div>
        </div>

        <div class="collapse navbar-collapse" id="navigation">
            <ul class="nav navbar-nav navbar-right">
                <?php
                if (!empty($menu)) {
                    foreach ($menu as $val) {
                        if (!empty($val['url']) && $val['url'] != '/') {
                            $url = Yii::$app->urlManager->createUrl([$val['url']]);
                            if (!empty($val['params'])) {
                                $url .= (strpos($url, '?') ? '&'.$val['params'] : '?'.$val['params']);
                            }
                        }else{
                            $url = '/';
                        }
                        ?>
                        <li><a href="<?=$url?>" data-code="<?=$val['code']?>"><?=$val['name']?></a></li>
                        <?php
                    }
                }else{
                    ?>
                    <li><a href="/"><?=Yii::t('frontend', 'home')?></a></li>
                    <?php
                }
                ?>
            </ul>
        </div>
    </div>
</nav>
